﻿namespace cmdVigenereGenetic
{
    public static class FrequencyOfBigrams
    {
        // столбцы ё == е (7 9 32), Ъ == ь (0 0 1 0 1)
        // строки ё == е (2 9 18), Ъ == ь ()
        private static List<double[]> bigrams1 = new()
            {
                new double[] { 2,  12, 35, 8,  14, 7,  7,  6,  15, 7,  7,  19, 27, 19, 45, 3,  11, 26, 31, 27, 3,  1,  10, 6,  7,  10, 1,  0,  0,  0,  2,  6,  9,  },
                new double[] { 5,  0,  0,  0,  0,  9,  9,  1,  0,  6,  0,  0,   6,  0,  2, 21, 0,  8,  1,  0,  6,  0,  0,  0,  0,  0,  1,  11, 0,  0,  0,  0,  2,  },
                new double[] { 35, 1,  5,  3,  3,  32, 32, 0,  2,  17, 0,  7,  10, 3,  9,  58, 6,  6,  19, 6,  7,  0,  1,  1,  2,  4,  1,  18, 1,  1,  2,  0,  3,  },
                new double[] { 7,  0,  0,  0,  3,  3,  3,  0,  0,  5,  0,  1,  5,  0,  1,  50, 0,  7,  0,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 25, 0,  3,  1,  1,  29, 29, 1,  1,  13, 0,  1,  5,  1,  13, 22, 3,  6,  8,  1,  10, 0,  0,  1,  1,  1,  0,  5,  1,  1,  0,  0,  1,  },
                new double[] { 2,  9,  18, 11, 27, 7,  7,  5,  10, 6,  15, 13, 35, 24, 63, 7,  16, 39, 37, 33, 3,  1,  8,  3,  7,  3,  3,  0,  0,  0,  1,  1,  2,  },
                new double[] { 2,  9,  18, 11, 27, 7,  7,  5,  10, 6,  15, 13, 35, 24, 63, 7,  16, 39, 37, 33, 3,  1,  8,  3,  7,  3,  3,  0,  0,  0,  1,  1,  2,  },
                new double[] { 5,  1,  0,  0,  6,  12, 12, 0,  0,  5,  0,  0,  0,  0,  6,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 35, 1,  7,  1,  5,  3,  3,  0,  0,  4,  0,  2,  1,  2,  9,  9,  1,  3,  1,  0,  2,  0,  0,  0,  0,  0,  0,  4,  0,  0,  0,  0,  4,  },
                new double[] { 4,  6,  22, 5,  10, 21, 21, 2,  23, 19, 11, 19, 21, 20, 32, 8,  13, 11, 29, 29, 3,  1,  17, 3,  11, 1,  1,  0,  0,  0,  1,  3,  17, },
                new double[] { 1,  1,  4,  1,  3,  0,  0,  1,  2,  4,  0,  5,  1,  2,  7,  9,  7,  3,  10, 2,  0,  0,  0,  1,  3,  2,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 24, 1,  4,  1,  0,  4,  4,  1,  1,  26, 0,  1,  4,  1,  2,  66, 2,  10, 3,  7,  10, 0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 25, 1,  1,  1,  1,  33, 33, 2,  1,  36, 0,  1,  2,  1,  8,  30, 2,  0,  3,  1,  6,  0,  4,  0,  1,  0,  0,  2,  30, 30, 0,  4,  9,  },
                new double[] { 18, 2,  4,  1,  1,  21, 21, 1,  2,  23, 0,  3,  1,  3,  7,  19, 5,  2,  5,  3,  9,  1,  0,  0,  2,  0,  0,  5,  1,  1,  1,  0,  3,  },
                new double[] { 54, 1,  2,  3,  3,  34, 34, 0,  0,  58, 0,  3,  0,  1,  24, 67, 2,  1,  9,  9,  7,  1,  0,  5,  2,  0,  0,  36, 3,  3,  0,  0,  5,  },
                new double[] { 1,  28, 84, 32, 47, 15, 15, 7,  18, 12, 29, 19, 41, 38, 30, 9,  18, 43, 50, 39, 3,  2,  5,  2,  12, 4,  3,  0,  0,  0,  2,  3,  2,  },
                new double[] { 7,  0,  0,  0,  0,  15, 15, 0,  0,  4,  0,  0,  9,  0,  1,  46, 0,  41, 1,  0,  6,  0,  0,  0,  0,  0,  0,  2,  0,  0,  0,  0,  2,  },
                new double[] { 55, 1,  4,  4,  3,  37, 37, 3,  1,  24, 0,  3,  1,  3,  7,  56, 2,  1,  5,  9,  16, 0,  1,  1,  1,  2,  0,  8,  3,  3,  0,  0,  5,  },
                new double[] { 8,  1,  7,  1,  2,  25, 25, 0,  0,  6,  0,  40, 13, 3,  9,  27, 11, 4,  11, 82, 6,  0,  1,  1,  2,  2,  0,  1,  8,  8,  0,  0,  17, },
                new double[] { 35, 1,  27, 1,  3,  31, 31, 0,  1,  28, 0,  5,  1,  1,  11, 56, 4,  26, 18, 2,  10, 0,  0,  0,  1,  0,  0,  28, 21, 21, 0,  0,  4,  },
                new double[] { 1,  4,  4,  4,  11, 2,  2,  6,  3,  2,  0,  8,  5,  5,  5,  1,  5,  7,  14, 7,  0,  0,  1,  0,  8,  3,  2,  0,  0,  0,  0,  9,  1,  },
                new double[] { 2,  0,  0,  0,  0,  2,  2,  0,  0,  2,  0,  0,  0,  0,  0,  1,  0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 4,  1,  4,  1,  3,  1,  1,  0,  2,  3,  0,  4,  3,  3,  4,  18, 5,  3,  4,  2,  2,  1,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 3,  0,  0,  0,  0,  7,  7,  0,  0,  10, 0,  2,  0,  0,  0,  1,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  },
                new double[] { 12, 0,  0,  0,  0,  23, 23, 0,  0,  13, 0,  2,  0,  0,  6,  0,  0,  0,  0,  7,  1,  0,  0,  0,  0,  1,  0,  0,  1,  1,  0,  0,  0,  },
                new double[] { 5,  0,  0,  0,  0,  11, 11, 0,  0,  14, 0,  1,  2,  0,  2,  2,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  0,  },
                new double[] { 3,  0,  0,  0,  0,  8,  8,  0,  0,  6,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 0,  1,  9,  1,  3,  12, 12, 0,  2,  4,  7,  3,  6,  6,  3,  2,  10, 3,  9,  4,  1,  0,  16, 0,  1,  2,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 0,  2,  4,  1,  1,  2,  2,  0,  2,  2,  0,  6,  0,  3,  13, 2,  4,  1,  11, 3,  0,  0,  0,  0,  1,  4,  0,  0,  0,  0,  1,  3,  1,  },
                new double[] { 0,  2,  4,  1,  1,  2,  2,  0,  2,  2,  0,  6,  0,  3,  13, 2,  4,  1,  11, 3,  0,  0,  0,  0,  1,  4,  0,  0,  0,  0,  1,  3,  1,  },
                new double[] { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  0,  1,  0,  0,  0,  1,  9,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  },
                new double[] { 0,  2,  1,  2,  1,  0,  0,  0,  3,  1,  0,  1,  0,  1,  1,  1,  3,  1,  1,  7,  0,  0,  0,  1,  1,  0,  4,  0,  0,  0,  0,  0,  0,  },
                new double[] { 1,  3,  9,  1,  3,  3,  3,  1,  5,  3,  2,  3,  3,  4,  6,  3,  6,  3,  6,  10, 0,  0,  2,  1,  4,  1,  1,  0,  0,  0,  1,  1,  1,  },
            };

        private static List<double[]> bigrams2 = new()
        {
            new double[] { 10.7,  8  ,  8.9,  9.8,  8.2,  9.1,  8.4,   7.8,  8.5,  9.5,  2.3,  9.1,  7.9,  8.8,  9.8,  9.4,  9.8,  8.7,  9.8,  9.3,  8.5,  6.3,  7.5,  5.8,  8.8,  6.4,  4.2,  0  ,  0  ,  0  ,  8.1,  4.1,  7.9,  0   , },
            new double[] { 9.5 ,  1.1,  6.3,  8  ,  6.6,  7.6,  7.2,   7.5,  8.3,  4.9,  6.9,  8.7,  8.9,  8.2,  8.3,  2.6,  6.8,  7.6,  8.5,  8.5,  4.4,  4.1,  6.9,  4.1,  6.9,  6.8,  5.6,  0  ,  0  ,  0  ,  1.6,  6.9,  7.7,  0   , },
            new double[] { 6.1 ,  6.5,  0  ,  3.9,  0  ,  3.2,  7.8,   1.4,  0  ,  6.8,  0  ,  4.9,  6.7,  3.8,  5.7,  7.7,  0  ,  7.2,  5.4,  1.4,  7.3,  0  ,  4  ,  0  ,  3  ,  2.4,  5.6,  5  ,  8.3,  4  ,  0  ,  2.3,  6.5,  0   , },
            new double[] { 8.7 ,  8.8,  0.7,  3.2,  3  ,  6.8,  8.6,   0  ,  6.3,  8.1,  0  ,  4.9,  6.5,  4.9,  7.4,  8.8,  6  ,  6.4,  8.3,  5.5,  6.6,  0  ,  4.2,  3.1,  5.3,  6.6,  2.6,  1.4,  8  ,  5.1,  0  ,  0  ,  5.4,  0   , },
            new double[] { 6.8 ,  7  ,  0  ,  1.9,  0.7,  7.1,  5.8,   0  ,  0.7,  6.5,  0  ,  4  ,  7.3,  3.7,  5.7,  9.1,  0  ,  6.4,  3.8,  1.9,  6.2,  0  ,  0  ,  0  ,  3.6,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0   , },
            new double[] { 6.7 ,  8.6,  3.3,  6.9,  2.6,  3.7,  8.5,   3  ,  2.5,  7.8,  0  ,  5.5,  6.5,  4.4,  7.6,  8.3,  4.5,  7.6,  5.8,  5.6,  7.7,  0  ,  3.8,  5.6,  4.1,  4.4,  0.7,  0.7,  6.2,  7  ,  0.7,  2.6,  6.1,  0.7 , },
            new double[] { 9.6 ,  3.5,  7.2,  7.3,  8.2,  8  ,  7.5,   6.8,  7.2,  4.9,  7.8,  7.2,  8.7,  8.5,  8.9,  5.7,  7.1,  8.8,  8.5,  8.7,  5.1,  3  ,  6.2,  5.9,  7.2,  7  ,  6.9,  0  ,  0  ,  0  ,  0  ,  5.5,  5.5,  0   , },
            new double[] { 6.4 ,  7.2,  3.2,  0  ,  1.4,  6.7,  8.5,   2.4,  0  ,  7.3,  0  ,  4.7,  2.9,  1.4,  6.7,  3  ,  0  ,  1.4,  2.4,  0  ,  5.8,  0  ,  0  ,  0  ,  2.3,  0  ,  0  ,  0  ,  0  ,  4  ,  0  ,  0.7,  0  ,  0   , },
            new double[] { 7.1 ,  8.5,  4.9,  6.9,  5.9,  6.6,  5.5,   3.9,  2.4,  6  ,  0  ,  4.8,  5.6,  5.6,  7.6,  6.3,  0  ,  5.6,  2.9,  2.1,  6.5,  0  ,  0  ,  0.7,  3  ,  1.9,  0  ,  3.8,  5.8,  4.7,  0  ,  0.7,  6.1,  0   , },
            new double[] { 9.7 ,  4.7,  6.6,  7.9,  6.4,  7.5,  7.7,   5.6,  7.6,  6.5,  7.2,  7.9,  8.5,  8  ,  8.1,  5.7,  5.5,  6.9,  7.7,  8.4,  2.2,  2.8,  7.6,  6.8,  7.5,  6.5,  5.1,  0  ,  0  ,  0  ,  0  ,  6  ,  7.3,  0   , },
            new double[] { 8.6 ,  0  ,  0  ,  0  ,  0  ,  5.6,  0  ,   0  ,  0.7,  0  ,  0  ,  4.9,  5.5,  3.8,  5.9,  1.8,  0  ,  0  ,  6.3,  5.9,  0  ,  0  ,  0  ,  3.8,  5.2,  5.3,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0   , },
            new double[] { 8.4 ,  8.9,  0.7,  5.5,  0  ,  0.7,  6.1,   3.4,  2.3,  7.8,  0  ,  2.6,  6.3,  1.1,  6.3,  9.2,  0  ,  7.4,  5.4,  6.3,  7.1,  0  ,  3.6,  2.9,  0  ,  2.5,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0   , },
            new double[] { 8.5 ,  8.7,  3.3,  2.7,  4.9,  3.1,  8.4,   5.8,  1.6,  8.7,  0  ,  5.7,  4.2,  2.8,  5.6,  8.7,  4.1,  0  ,  7.3,  4.7,  7.4,  0.7,  0  ,  0  ,  5.4,  0  ,  0  ,  0  ,  6.4,  8.6,  0  ,  6.8,  7.3,  0   , },
            new double[] { 8.7 ,  8.1,  2.9,  0.7,  4.4,  0  ,  8.4,   0  ,  0  ,  8  ,  0  ,  4.5,  4.6,  3.5,  7.4,  8.3,  3.9,  4.2,  4.7,  3.4,  7.8,  2.4,  0  ,  2.4,  4  ,  1.8,  0  ,  0  ,  6.8,  4.5,  0  ,  0.7,  6  ,  0   , },
            new double[] { 8.2 ,  9.3,  2.4,  2.7,  4  ,  5.7,  9.3,   1.6,  2.6,  9.1,  0  ,  5.6,  0  ,  0  ,  8  ,  9.3,  0  ,  4.6,  5.8,  6.1,  8  ,  3.6,  1.4,  5.5,  5.3,  2.5,  4.7,  0  ,  8  ,  7.1,  0  ,  5.4,  7.5,  0   , },
            new double[] { 10  ,  2.1,  8.3,  9.1,  8.5,  8.6,  7.7,   7.7,  7  ,  6.6,  8.1,  7.5,  8.8,  8.7,  8.8,  5.5,  7.3,  8.6,  8.8,  8.9,  4.6,  5.3,  6.2,  5  ,  7.8,  7  ,  5.6,  0  ,  0  ,  0  ,  1.9,  6.4,  6.6,  0   , },
            new double[] { 2.8 ,  6.8,  0  ,  0  ,  0.7,  0  ,  8.1,   0  ,  0  ,  6.9,  0  ,  4.4,  6.7,  0  ,  4.7,  9.2,  3.4,  8.9,  4  ,  4.3,  6.8,  0  ,  0  ,  2.2,  3.1,  1.9,  0  ,  0  ,  5.5,  5.2,  0  ,  0  ,  6.4,  0   , },
            new double[] { 6.1 ,  9  ,  5.2,  6  ,  5.5,  5.8,  8.7,   5.7,  4  ,  8.6,  0  ,  5.4,  4.2,  5.9,  6.6,  9  ,  4.7,  2.2,  5  ,  6.5,  8  ,  5.7,  4.3,  2.9,  4.3,  5.5,  2.6,  0  ,  6.9,  6.9,  0  ,  5.3,  7  ,  0   , },
            new double[] { 8   ,  7.5,  4.6,  7.4,  3.4,  5.4,  8.2,   3.3,  2.3,  7.3,  0  ,  8.4,  8  ,  7.1,  6.8,  8  ,  7.5,  5.2,  6.7,  9.3,  6.7,  1.8,  5.3,  4.1,  6  ,  4.4,  0  ,  2.6,  5.4,  8.1,  0  ,  5.6,  8.3,  6.9 , },
            new double[] { 8.3 ,  8.7,  2.2,  7.9,  2.3,  4.7,  8.8,   0  ,  3  ,  8.2,  0  ,  6  ,  5.5,  3.6,  7.1,  9.7,  4.2,  8.1,  7.1,  4.4,  7.6,  0.7,  2.8,  4.2,  5.8,  2.3,  3.4,  2.6,  7.3,  8.9,  2.3,  4.5,  6.1,  0   , },
            new double[] { 8.5 ,  4.4,  6.7,  6.5,  7.4,  7.6,  5.4,   7.6,  5.5,  1.9,  5.4,  6.5,  7.3,  7.4,  6.3,  1.4,  6.7,  6.4,  7  ,  7.4,  0  ,  2.7,  6.1,  1.9,  6.8,  6.4,  5.9,  0  ,  0  ,  0  ,  0  ,  6.8,  4.1,  0   , },
            new double[] { 1.8 ,  5.5,  0  ,  0  ,  0  ,  0  ,  4.1,   0  ,  0  ,  5.9,  0  ,  0  ,  2.5,  1.4,  0  ,  4.9,  0  ,  4.8,  2.1,  2.5,  4.7,  2.2,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  3.1,  4.7,  0  ,  0  ,  0  ,  0   , },
            new double[] { 7.8 ,  6.1,  0  ,  5.3,  0  ,  0  ,  5.8,   0  ,  2.1,  6.3,  0  ,  0  ,  5  ,  4.2,  5  ,  7.8,  0  ,  4.5,  3.4,  2.3,  5.2,  0  ,  0  ,  0  ,  1.4,  2.8,  0  ,  0  ,  0  ,  0  ,  0.7,  0  ,  0  ,  0   , },
            new double[] { 5.3 ,  6.3,  0  ,  3.3,  0  ,  0  ,  6.7,   0  ,  0  ,  5.7,  0  ,  3.2,  0  ,  1.1,  0  ,  5.3,  0  ,  0  ,  0  ,  1.9,  5.3,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  5.2,  0  ,  0  ,  0  ,  0  ,  0   , },
            new double[] { 5.3 ,  7.9,  0  ,  0  ,  0  ,  0  ,  8.4,   0  ,  0  ,  7.5,  0  ,  6.3,  3  ,  1.9,  6.9,  4.4,  0  ,  4.5,  0  ,  8.4,  6.6,  0  ,  0  ,  0  ,  0  ,  5  ,  0  ,  0  ,  0  ,  5.5,  0  ,  0  ,  0  ,  0   , },
            new double[] { 3.9 ,  6.9,  0  ,  2.1,  0  ,  0  ,  7.7,   0  ,  0  ,  7.3,  0  ,  6.2,  6.3,  2.6,  6.1,  5.2,  0  ,  0  ,  0  ,  4.1,  5.4,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  6.5,  0  ,  0  ,  0  ,  0   , },
            new double[] { 1.1 ,  6  ,  0  ,  0  ,  0  ,  0  ,  7.4,   0  ,  0  ,  6.5,  0  ,  0  ,  0  ,  0  ,  4  ,  0.7,  0  ,  1.1,  0  ,  0  ,  5.2,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  3.6,  0  ,  0  ,  0  ,  0   , },
            new double[] { 0   ,  0  ,  0  ,  0  ,  0  ,  0  ,  3.8,   0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  5.2,  0   , },
            new double[] { 8.2 ,  0  ,  5  ,  6.8,  4.7,  5.1,  6.8,   3.1,  4.2,  1.8,  7.2,  5.2,  7.6,  7  ,  5.2,  0  ,  4.7,  5.4,  6.6,  6.7,  0.7,  0  ,  6.9,  0  ,  5.2,  6.2,  2.3,  0  ,  0  ,  0  ,  0  ,  0  ,  1.1,  0   , },
            new double[] { 9   ,  0  ,  4.9,  3.4,  5  ,  3  ,  6.1,   0  ,  5.1,  4.8,  0  ,  7.2,  0  ,  5.9,  7.8,  1.4,  0  ,  0  ,  6.8,  5.2,  0  ,  2.6,  4.9,  4.2,  4.1,  5.8,  3.3,  0  ,  0  ,  0  ,  0  ,  5.9,  6.2,  0   , },
            new double[] { 0   ,  0  ,  0  ,  1.8,  2.5,  2.1,  0  ,   0  ,  0  ,  0  ,  2.7,  4.2,  2.6,  1.6,  3.2,  0  ,  3.4,  0  ,  1.9,  8  ,  0  ,  2.2,  3.7,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0   , },
            new double[] { 7.6 ,  0  ,  5.8,  1.1,  1.4,  5.9,  0  ,   2.7,  2.2,  1.6,  0  ,  2.8,  2.6,  3.9,  3.4,  0  ,  0  ,  4  ,  5.3,  5.9,  0  ,  0  ,  2.1,  3.6,  4.7,  4.2,  5.6,  0  ,  0  ,  0  ,  0  ,  3.7,  0  ,  0   , },
            new double[] { 9.1 ,  0  ,  3  ,  5.8,  4.2,  6.3,  4.8,   4.7,  5.4,  3  ,  4.5,  5.2,  6.8,  6  ,  6.5,  0  ,  4  ,  4.5,  6.5,  7.4,  0  ,  0  ,  5.3,  4.3,  5.1,  2.4,  5  ,  0  ,  0  ,  0  ,  0  ,  4.8,  4.5,  0   , },
            new double[] { 6.8 ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,   0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0.7,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0   , },
        };

        private static string alphabet1 = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
        private static string alphabet2 = " абвгдежзийклмнопрстуфхцчшщъыьэюяё";

        /// <summary>
        /// Считает частоту биграмм в тексте и записывает значение в переменную
        /// </summary>
        /// <param name="text"></param>
        /// <param name="frequencyOfBigrams"></param>
        /// <exception cref="ArgumentException"></exception>
        public static void FindFrequencyOfBigrams(string text, out double frequencyOfBigrams, int type = 2)
        {
            string alphabet;
            List<double[]> bigrams;
            if (type == 1)
            {
                alphabet = alphabet1;
                bigrams = bigrams1;
            }
            else
            {
                alphabet = alphabet2;
                bigrams = bigrams2;
            }

            frequencyOfBigrams = 0;
            if (text is null || text.Length < 3) throw new ArgumentException("Текст не может быть пустым или меньше 3 символов");

            string Aij = text[0].ToString() + text[1];

            if (alphabet.Contains(Aij[0]) && alphabet.Contains(Aij[1]))
            {
                frequencyOfBigrams += bigrams[alphabet.IndexOf(Aij[0])][alphabet.IndexOf(Aij[1])];
            }

            for (int i = 2; i < text.Length; i++)
            {
                Aij = Aij[1].ToString() + text[i];
                if (alphabet.Contains(Aij[0]) && alphabet.Contains(Aij[1]))
                {
                    frequencyOfBigrams += bigrams[alphabet.IndexOf(Aij[0])][alphabet.IndexOf(Aij[1])];
                }
            }
        }
    }
}
